﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.DescendanttransferCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.DescendanttransferCommandHandler
{
	/// <summary>
	/// 添加后裔转种
	/// </summary>
	/// <returns></returns>
	public class AddDescendanttransferCommandHandler : IRequestHandler<AddDescendanttransferCommand, int>
	{
		/// <summary>
		/// 接口
		/// </summary>
		private readonly IDescendantTransferService _descendantTransferService;
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="descendantTransferService"></param>

		public AddDescendanttransferCommandHandler(IDescendantTransferService descendantTransferService)
		{
			_descendantTransferService = descendantTransferService;
		}
		/// <summary>
		/// 添加后裔转种
		/// </summary>
		/// <param name="request"></param>
		/// <param name="cancellationToken"></param>
		/// <returns></returns>
		/// <exception cref="NotImplementedException"></exception>
		public async Task<int> Handle(AddDescendanttransferCommand request, CancellationToken cancellationToken)
		{
			var result= await _descendantTransferService.AddDelDescendanttransfer(request.entity);
			return result;
		}
	}
}
